<template>
  <view class="container screen-width">
    <view class="summary">
      全部订单
      <text class="summary-hint">（{{ total }}）</text>
    </view>
    <scroll-view class="list" :scroll-y="true" @scrolltolower="fetchData()">
      <view class="item u-flex u-row-between" v-for="(item, index) in list" :key="index">
        <view>
          <view class="no">{{ item.id }}</view>
          <view class="desc">{{ item.description }}</view>
        </view>
        <view>
          <view class="time">{{ item.createTime }}</view>
          <view class="fund">{{ item.orderMoney / 100 }}</view>
        </view>
      </view>

      <u-loadmore
        bg-color="#ffffff"
        style="width: 100%;  margin-top: 15rpx;  padding-right: 30rpx"
        :status="status"
      />
    </scroll-view>
    <Festival></Festival>
  </view>
</template>

<script>
import {
  deptFollowList,
  comFollowList,
  comList,
  orderList
} from "../../util/api/user";
export default {
  data() {
    return {
      total: 0,
      current: 0,
      list: [],
      tabList: [
        {
          name: "订阅的部门",
          count: 5
        },
        {
          name: "关注的企业",
          count: 0
        }
      ],
      params: {
        pageNo: 1,
        pageSize: 15
      },
      status: "loadmore"
    };
  },
  onLoad() {
    this.fetchData(true);
  },
  methods: {
    handleChange(index) {
      this.current = index;
      this.fetchData(true);
    },
    getPromise() {
      switch (this.current) {
        case 0:
          return deptFollowList(this.params);
        case 1:
          return comFollowList(this.params);
      }
    },
    fetchData(reset = false) {
      if (reset) {
        this.resetPagination();
      }
      uni.showLoading();
      this.status = "loading";
      orderList(this.params).then(res => {
        uni.hideLoading();
        this.$nextTick(() => {
          let records = res.result.records;
          // uni.stopPullDownRefresh();
          console.log(records);
          this.total = res.result.total;
          if (!records.length) {
            this.status = "nomore";
            return;
          }
          this.list = reset ? records : this.list.concat(records);
          this.params.pageNo += 1;
          this.status = "loadmore";
        });
      });
    },
    resetPagination() {
      this.params.pageNo = 1;
      this.list = [];
      this.status = "loadmore";
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  height: 100%;
  max-height: 100%;

  .summary {
    height: 120rpx;
    padding: 0 30rpx;
    line-height: 120rpx;
    font-size: 32rpx;
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    text-align: left;
    color: #333333;

    &-hint {
      color: #1678ff;
    }
  }

  .list {
    height: calc(100% - 100rpx);
    width: 100%;
    background: #fff;
    padding: 0 30rpx;
    padding-bottom: 120rpx;

    .item {
      height: 200rpx;
      border-bottom: 1rpx solid #ebebeb;

      .no {
        font-size: 22rpx;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        text-align: left;
        color: #333333;
        margin-bottom: 12rpx;
      }
      .desc {
        font-size: 32rpx;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        text-align: left;
        color: #333333;
      }
      .time {
        font-size: 22rpx;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        text-align: left;
        color: #aaaaaa;
        margin-bottom: 12rpx;
      }
      .fund {
        font-size: 26rpx;
        font-family: PingFang SC, PingFang SC-Bold;
        font-weight: 700;
        text-align: right;
        color: #333333;
      }

      .title {
        font-size: 28rpx;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        text-align: left;
        color: #333333;
      }

      .logo {
        margin-right: 70rpx;
      }
      .date {
        font-size: 22rpx;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        text-align: left;
        color: #aaaaaa;
      }

      .sub {
      }
      .sub-cancel {
        width: 120rpx;
        height: 48rpx;
        opacity: 1;
        background: #e8f3ff;
        border-radius: 8rpx;
        color: #1678ff;
        line-height: 48rpx;
        text-align: center;
      }
    }
  }
}
</style>
